package com.ipt.frm.pw;

import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class LogOutServlet
 */
public class LogOutServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	static Properties properties;   
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LogOutServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session = request.getSession();
		session.invalidate();
		properties = new Properties();
		properties = (Properties) getServletContext().getAttribute("propiedad");
		//TODO meter estos literales en un fichero .properties
		//msg error
		Mensaje mensaje;
		mensaje = new Mensaje(TipoMensaje.ERROR,properties.getProperty("logout.success"));
		//forward
		request.setAttribute("MSG", mensaje);
		
		request.getRequestDispatcher("login.jsp").forward(request, response);
	}
}
